<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>CryoBB 1.0.0 Demo</title>
<style type="text/css">
body {
	font-size: 12px;
	font-family: verdana, arial, tahoma;
	color: #000;
}

h1 {
	font-size: 20px;
}

.display
{
	padding: 5px;
	border: solid 1px #e6e6e6;
	background-color: #F5F5DC;
	white-space: normal;
	word-wrap: break-word;
}

blockquote {
	border: solid 1px #e6e6e6;
	padding: 3px;
}

.code
{
	border: solid 1px green;
	padding: 3px;
}
</style>
</head>
<body><?php

// Library includes
require_once '../CryoBB/Base.php';
require_once '../CryoBB/Tag.php';
require_once '../CryoBB/Tag/Parameter.php';
require_once '../CryoBB/Emoticons.php';
require_once '../CryoBB/Processor.php';
require_once '../CryoBB/Match.php';

// Demo specific includes
require_once 'processors/Upper.php';
require_once 'processors/Url.php';

//base
$base = new CryoBB_Base();

$b = new CryoBB_Tag('b');
$b->setOpenTag('<strong>');
$b->setCloseTag('</strong>');

$u = new CryoBB_Tag('u');
$u->setOpenTag('<span style="text-decoration: underline">');
$u->setCloseTag('</span>');

$i = new CryoBB_Tag('i');
$i->setOpenTag('<em>');
$i->setCloseTag('</em>');

$url = new CryoBB_Tag_Parameter('url');
$url->setOpenTagParameter('<a href="{placeholder}">', '{placeholder}');
$url->setCloseTag('</a>');

$color = new CryoBB_Tag_Parameter('color');
$color->setOpenTag('<span>');
$color->setOpenTagParameter('<span style="color: {placeholder}">', '{placeholder}');
$color->setCloseTag('</span>');

$quote = new CryoBB_Tag_Parameter('quote');
$quote->setOpenTag('<div><strong>Quote:</strong></div><blockquote>');
$quote->setOpenTagParameter('<div><strong>{placeholder} wrote:</strong></div><blockquote>', '{placeholder}');
$quote->setCloseTag('</blockquote>');
$quote->parseParameter(true);

$upper = new CryoBB_Tag('upper');
$upper->setProcessor(new Processor_Upper());

$code = new CryoBB_Tag('code');
$code->parseContents(false);
$code->setOpenTag('<pre class="code">');
$code->setCloseTag('</pre>');

$emoticons = new CryoBB_Emoticons();
$emoticons->isCaseSensitive(false);
$emoticons->addEmoticons(
	array(
		':smile:' => '<img src="emoticons/smile.gif" alt="Smile">',
		':sad:' => '<img src="emoticons/sad.gif" alt="Sad">'
	)
);

//add tags to base
$base->addTags($b, $u, $i, $url, $color, $quote, $upper, $code);

//add emoticons to base
$base->addEmoticons($emoticons);

if (!empty($_POST['action']) && ($_POST['action'] == 'doCryoBB'))
{
	if (empty($_POST['input']) !== true)
	{
		if (get_magic_quotes_gpc())
		{
			$_POST['input'] = stripslashes($_POST['input']);
		}
		
		//converts the input into output
		$output = $base->make($_POST['input']);
		
		
		//this is just for the demo purposes
		$input = htmlentities($_POST['input'], ENT_QUOTES);
		$outputraw = htmlentities($output, ENT_QUOTES);
		
		echo '<h1>Input</h1>';
		echo '<pre class="display">';
		echo $input;
		echo '</pre>';
		
		echo '<h1>Output</h1>';
		echo '<pre class="display">';
		echo $outputraw;
		echo '</pre>';
		
		echo '<h1>Display</h1>';
		echo '<div class="display">';
		echo $output;
		echo '</div>';
	}
}

?><h1>Post Input String</h1>
<div>Defined tags are bold [b], underline [u], italic [i], url [url], color [color], quote [quote], upper [upper], and code [code].  Defined emoticons are :smile: and :sad:</div>
<p><strong>Usage</strong></p>
<ul>
	<li> Bold - [b]text[/b]</li>
	<li> Underline - [u]text[/u]</li>
	<li> Italic - [i]text[/i]</li>
	<li> URL - [url=http://example.com]text[/url], [url="http://example.com"]text[/url], [url]http://example.com[/url]</li>
	<li> Color - [color=#FF0000]text[/color]</li>
	<li> Quote - [quote=name]text[/quote], [quote="name"]text[/quote], [quote]text[/quote]</li>
	<li> Upper - [upper]text[/upper]</li>
	<li> Code - [code]text[/code]</li>
	<li> Emoticons - enter text :smile: or :sad:</li>
</ul>
<form action="index.php" method="post">
<input type="hidden" name="action" value="doCryoBB">
<textarea name="input" rows="5" cols="50"><?php echo empty($_POST['input']) !== true ? htmlentities($_POST['input'], ENT_QUOTES) : '' ?></textarea>
<p><input class="submit" type="submit" value="Submit"></p>
</form>
</body>
</html>